/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * NuGat-API named Chameleon developed by Simon De Baets to Verimag.
 *
 */
package chameleon.model.NuGatStructure.game;

import chameleon.gameSolver.NuGat.NuGatInterface;
import chameleon.model.NuGatStructure.NuGatStructure;
import com.sun.jna.Pointer;

/**
 *  This class is a wrapper to the C structure GamePlayer.c
 * @author simon
 */
public class GamePlayer extends NuGatStructure {
    
    public GamePlayer (Pointer player, NuGatInterface  nugat){
        super( player, nugat);
    }
    
    public GamePlayer (String name, NuGatInterface nugat){
        super (nugat.Game_StrToPlayer(nugat.find_string(name)),nugat);
    }
    
    public boolean equals (GamePlayer player){
        return this.ptr() == player.ptr();
    }
    
    public String toString(){
        return nugat_.get_text(nugat_.Game_PlayerToStr(this.ptr()));
    }
    
    public boolean isPLayer1(){
        return this.toString().equals(nugat_.PLAYER_NAME_1);
    }
    
    public boolean isPLayer2(){
        return this.toString().equals(nugat_.PLAYER_NAME_2);
    }
    
    public int getPLayer(){
        if (isPLayer1())
            return nugat_.PLAYER_1;
        else if (isPLayer2())
            return nugat_.PLAYER_2;
        else
            throw new RuntimeException("GamePlayer :: Unknow Player");
    }
    
}
